const config = require('../../../config/config.local');
const amazonMws = require('amazon-mws')(config.AWSAccessKeyId, config.AWSSecretKey);
const isProduction = process.env.NODE_ENV === 'production';

const cancelShipment = {};
cancelShipment.generateOption = function(seller_id, mws_auth_token, shipmentId){
  let baseOption = {
    'Version': '2015-06-01',
    'Action': 'CreateShipment',
    'SellerId': seller_id,
    'MWSAuthToken': mws_auth_token,
    'shipmentId': shipmentId,
  };

  return baseOption;
};

cancelShipment._ = function(options) {
  if (!isProduction) {
    return amazonMws.merchantFulfillment.create(options);
  } else {
    console.error("bot not implemented!");
  }
};

cancelShipment.cancelShipment = function(seller_id, mws_auth_token, shipmentId) {
  return this._(this.generateOption(seller_id, mws_auth_token, shipmentId));
};

module.exports = cancelShipment;